// noinspection NpmUsedModulesInstalled,JSCheckFunctionSignatures,SpellCheckingInspection

import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/',
    component: Layout,
    redirect: '/',
    name: '蛋蛋首页',
    meta: { title: '蛋蛋首页', icon: 'home' },
    children: []
  },

  {
    path: '/sta',
    component: Layout,
    redirect: '/sta/create',
    name: '统计分析',
    meta: { title: '统计分析', icon: 'statistics' },
    children: [
      {
        path: 'create',
        name: '生成数据',
        component: () => import('@/views/sta/create'),
        meta: { title: '生成数据', icon: 'linechart' }
      },
      {
        path: 'show',
        name: '图表显示',
        component: () => import('@/views/sta/show'),
        meta: { title: '图表显示', icon: 'statistics' }
      }
    ]
  },

  {
    path: '/banner',
    component: Layout,
    redirect: '/banner/list',
    name: '轮播图管理',
    meta: { title: '轮播图管理', icon: 'banner' },
    children: [
      {
        path: 'show',
        name: '轮播图展示',
        component: () => import('@/views/banner/show'),
        meta: { title: '轮播图展示', icon: 'banner' }
      },
      {
        path: 'list',
        name: '轮播图列表',
        component: () => import('@/views/banner/list'),
        meta: { title: '轮播图列表', icon: 'imglist' }
      },
      {
        path: 'add',
        name: '添加轮播图',
        component: () => import('@/views/banner/add'),
        meta: { title: '添加轮播图', icon: 'addimg' }
      },
      {
        path: 'add/:id',
        name: '编辑轮播图',
        component: () => import('@/views/banner/add'),
        meta: { title: '编辑轮播图', noCache: true },
        hidden: true
      },
    ]
  },

  {
    path: '/image',
    component: Layout,
    redirect: '/image/list',
    name: '图片管理',
    meta: { title: '图片管理', icon: 'image' },
    children: [
      {
        path: 'list',
        name: '图片列表',
        component: () => import('@/views/image/list'),
        meta: { title: '图片列表', icon: 'imglist' }
      },
      {
        path: 'add',
        name: '添加图片',
        component: () => import('@/views/image/add'),
        meta: { title: '添加图片', icon: 'addimg' }
      },
      {
        path: 'add/:id',
        name: '编辑图片',
        component: () => import('@/views/image/add'),
        meta: { title: '编辑图片', noCache: true },
        hidden: true
      },
    ]
  },

  {
    path: '/video',
    component: Layout,
    redirect: '/video/list',
    name: '视频管理',
    meta: { title: '视频管理', icon: 'video' },
    children: [
      {
        path: 'list',
        name: '视频列表',
        component: () => import('@/views/video/list'),
        meta: { title: '视频列表', icon: 'video' }
      },
      {
        path: 'add',
        name: '添加视频',
        component: () => import('@/views/video/add'),
        meta: { title: '添加视频', icon: 'addvideo' }
      },
      {
        path: 'add/:id',
        name: '编辑视频',
        component: () => import('@/views/video/add'),
        meta: { title: '编辑视频', noCache: true },
        hidden: true
      },
    ]
  },

  {
    path: '/article',
    component: Layout,
    redirect: '/article/list',
    name: '文章管理',
    meta: { title: '文章管理', icon: 'article' },
    children: [
      {
        path: 'classes',
        name: '管理分类',
        component: () => import('@/views/article/classes'),
        meta: { title: '管理分类', icon: 'articleClass' }
      },
      {
        path: 'list',
        name: '文章列表',
        component: () => import('@/views/article/list'),
        meta: { title: '文章列表', icon: 'article' }
      },
      {
        path: 'add',
        name: '添加文章',
        component: () => import('@/views/article/add'),
        meta: { title: '添加文章', icon: 'addarticle' }
      },
      {
        path: 'list/:id',
        name: '分类查看',
        component: () => import('@/views/article/list'),
        meta: { title: '分类查看', noCache: true },
        hidden: true
      },
      {
        path: 'add/:id',
        name: '编辑文章',
        component: () => import('@/views/article/add'),
        meta: { title: '编辑文章', noCache: true },
        hidden: true
      },
      {
        path: 'show/:id',
        name: '展示文章',
        component: () => import('@/views/article/show'),
        meta: { title: '展示文章', noCache: true },
        hidden: true
      },
    ]
  },

  {
    path: '/hyperlink',
    component: Layout,
    redirect: '/hyperlink/list',
    name: '超链接管理',
    meta: { title: '超链接管理', icon: 'hyperlink' },
    children: [
      {
        path: 'list',
        name: '超链接列表',
        component: () => import('@/views/hyperlink/list'),
        meta: { title: '超链接列表', icon: 'hyperlink' }
      },
      {
        path: 'add',
        name: '添加超链接',
        component: () => import('@/views/hyperlink/add'),
        meta: { title: '添加超链接', icon: 'addhyperlink' }
      },
      {
        path: 'add/:id',
        name: '编辑超链接',
        component: () => import('@/views/hyperlink/add'),
        meta: { title: '编辑超链接', noCache: true },
        hidden: true
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({

  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

const router = createRouter()

export default router

